﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ImportMFGsFromFile.PlanningFieldToRoboticParamComparator
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using Tecnomatix.Engineering;
using Tecnomatix.Planning;


namespace DnProcessSimulateCommands.ImportMFGsFromFile;

internal class PlanningFieldToRoboticParamComparator
{
  private object PlanningFieldTypeRoboticParamTypeMap(
    TxPlanningFieldType fieldType,
    object fieldValue,
    TxRoboticParam roboticParam,
    PlanningFieldToRoboticParamComparator.Executor exec)
  {
    object obj = (object) null;
    switch (fieldType - 1)
    {
      case 0:
        TxRoboticBoolParam roboticParam1 = roboticParam as TxRoboticBoolParam;
        obj = exec((object) roboticParam1, (object) roboticParam1.Value, fieldValue);
        break;
      case 1:
      case 2:
        TxRoboticIntParam roboticParam2 = roboticParam as TxRoboticIntParam;
        obj = exec((object) roboticParam2, (object) roboticParam2.Value, fieldValue);
        break;
      case 3:
      case 4:
        TxRoboticDoubleParam roboticParam3 = roboticParam as TxRoboticDoubleParam;
        obj = exec((object) roboticParam3, (object) roboticParam3.Value, fieldValue);
        break;
      case 5:
        TxRoboticStringParam roboticParam4 = roboticParam as TxRoboticStringParam;
        obj = exec((object) roboticParam4, (object) roboticParam4.Value, fieldValue);
        break;
      default:
        if (fieldType == 19)
          goto case 1;
        break;
    }
    return obj;
  }

  private object RoboticParamCreator(
    object oldRoboticParam,
    object roboticParamValue,
    object newRoboticParamValue)
  {
    return Activator.CreateInstance(oldRoboticParam.GetType(), (object) (oldRoboticParam as TxRoboticParam).Type, newRoboticParamValue);
  }

  private object RoboticParamToPlanningFieldCompare(
    object oldRoboticParam,
    object roboticParamValue,
    object fieldValue)
  {
    return (object) roboticParamValue.Equals(fieldValue);
  }

  public TxRoboticParam CreateRoboticParamFromMappedMfgField(
    TxRoboticParam roboticParam,
    TxPlanningFieldType fieldType,
    object fieldValue)
  {
    return (TxRoboticParam) this.PlanningFieldTypeRoboticParamTypeMap(fieldType, fieldValue, roboticParam, new PlanningFieldToRoboticParamComparator.Executor(this.RoboticParamCreator));
  }

  public bool ComparePlanningFieldToRoboticParamValue(
    TxPlanningFieldType fieldType,
    object fieldValue,
    TxRoboticParam roboticParam)
  {
    return (bool) this.PlanningFieldTypeRoboticParamTypeMap(fieldType, fieldValue, roboticParam, new PlanningFieldToRoboticParamComparator.Executor(this.RoboticParamToPlanningFieldCompare));
  }

  private delegate object Executor(object roboticParam, object roboticParamValue, object value);
}
